// MyFamily - XML based genealogy program.
// Copyright (C) 2006  Doug Swisher
// See the file COPYING.txt for license details.

using System;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

using WebLib;


namespace CommonGui
{
    public partial class WebSiteResultsDialog : Form
    {
        private WebSiteResults webSiteResults;

        public WebSiteResultsDialog(WebSiteResults webSiteResults)
        {
            this.webSiteResults = webSiteResults;

            InitializeComponent();
        }

        private void WebSiteResultsDialog_Load(object sender, EventArgs e)
        {
            this.OutputDirectoryTextBox.Text = this.webSiteResults.OutputDirectoryInfo.FullName;

            this.WarningCountTextBox.Text = this.webSiteResults.WarningCount.ToString();

            foreach (string message in webSiteResults.Messages)
            {
                this.MessagesTextBox.AppendText(message + "\r\n");
            }
        }

        private void ViewWebSiteButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                string url = Path.Combine(this.webSiteResults.OutputDirectoryInfo.FullName, "default.htm");

                Process.Start(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Web browser launch threw an exception");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        private void MyOkButton_Click(object sender, EventArgs e)
        {

        }
    }
}